home *** CD-ROM | disk | FTP | other *** search
/ AGA Toolkit '97 / The AGA Toolkit '97.iso / programming / gui / gadutil / include / libraries / gadutil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-07  |  17.2 KB  |  495 lines

  1. #ifndef LIBRARIES_GADUTIL_H
  2. #define LIBRARIES_GADUTIL_H
  3. /*------------------------------------------------------------------------**
  4. **
  5. **    $VER: gadutil.h 37.0 (29.04.96)
  6. **
  7. **    Filename:    libraries/gadutil.h
  8. **    Version:    37.0
  9. **    Date:        29-Apr-96
  10. **
  11. **    GadUtil definitions, a dynamic gadget layout system.
  12. **
  13. **    © Copyright 1994-1996 by P-O Yliniemi and Staffan Hämälä.
  14. **
  15. **    All Rights Reserved.
  16. **
  17. **------------------------------------------------------------------------*/
  18.  
  19. #ifndef EXEC_TYPES_H
  20. #include <exec/types.h>
  21. #endif
  22.  
  23. #ifndef EXEC_LIBRARIES_H
  24. #include <exec/libraries.h>
  25. #endif
  26.  
  27. #ifndef UTILITY_TAGITEM_H
  28. #include <utility/tagitem.h>
  29. #endif
  30.  
  31. #ifndef INTUITION_INTUITION_H
  32. #include <intuition/intuition.h>
  33. #endif
  34.  
  35. /*------------------------------------------------------------------------**
  36. **
  37. ** Extended gadget types available in GadUtil.library.
  38. **
  39. */
  40.  
  41. #define IMAGE_KIND    50
  42. #define LABEL_KIND    51            /* Not implemented */
  43. #define DRAWER_KIND    52
  44. #define FILE_KIND    53
  45. #define BEVELBOX_KIND    54
  46. #define PROGRESS_KIND    55
  47.  
  48. /*--------------- Minimum recommended sizes for some gadgets -------------*/
  49. #define FILEKIND_WIDTH  20
  50. #define FILEKIND_HEIGHT 14
  51.  
  52. #define DRAWERKIND_WIDTH  20
  53. #define DRAWERKIND_HEIGHT 14
  54.  
  55. /*-------------------------- Bevel box frame types -----------------------*/
  56. #define BFT_BUTTON    0    /* Normal button bevel box border */
  57. #define BFT_RIDGE    1    /* STRING_KIND bevel box border      */
  58. #define BFT_DROPBOX    2    /* Icon dropbox type border      */
  59.  
  60. #define BFT_HORIZBAR    10    /* Horizontal shadowed line       */
  61. #define BFT_VERTBAR    11    /* Vertical shadowed line         */
  62.  
  63. /*------------------------- Text placement flags -------------------------*/
  64. #define BB_TEXT_ABOVE    0    /* Place bevel box text above the
  65.                  * upper border   ___ Example ___ */
  66.  
  67. #define BB_TEXT_IN    1    /* Place bevel box text centered at
  68.                  * the upper border --- Example --- */
  69.  
  70. #define BB_TEXT_BELOW    2    /* Place bevel box text below the
  71.                  * upper border   ___        ___
  72.                  *                    Example      */
  73.  
  74. #define BB_TEXT_CENTER    0    /* Place the text centered at the
  75.                  * upper border (default)         */
  76.  
  77. #define BB_TEXT_LEFT    4    /* Place the text left adjusted   */
  78.  
  79. #define BB_TEXT_RIGHT    8    /* Place the text right adjusted  */
  80.  
  81. /*--------------- Alternatives to text placement flags -------------------*/
  82. #define BB_TEXT_ABOVE_CENTER    BB_TEXT_ABOVE|BB_TEXT_CENTER
  83. #define BB_TEXT_ABOVE_LEFT    BB_TEXT_ABOVE|BB_TEXT_LEFT
  84. #define BB_TEXT_ABOVE_RIGHT    BB_TEXT_ABOVE|BB_TEXT_RIGHT
  85.  
  86. #define BB_TEXT_IN_CENTER    BB_TEXT_IN|BB_TEXT_CENTER
  87. #define BB_TEXT_IN_LEFT        BB_TEXT_IN|BB_TEXT_LEFT
  88. #define BB_TEXT_IN_RIGHT    BB_TEXT_IN|BB_TEXT_RIGHT
  89.  
  90. #define BB_TEXT_BELOW_CENTER    BB_TEXT_BELOW|BB_TEXT_CENTER
  91. #define BB_TEXT_BELOW_LEFT    BB_TEXT_BELOW|BB_TEXT_LEFT
  92. #define BB_TEXT_BELOW_RIGHT    BB_TEXT_BELOW|BB_TEXT_RIGHT
  93.  
  94. /*-----------------------Text Shadow placement ---------------------------*/
  95. #define BB_SHADOW_DR    0    /* Place the shadow at x+1, y+1   */
  96. #define BB_SHADOW_UR    16    /* Place the shadow at x+1, y-1   */
  97. #define BB_SHADOW_DL    32    /* Place the shadow at x-1, y+1   */
  98. #define BB_SHADOW_UL    48    /* Place the shadow at x-1, y-1   */
  99.  
  100. /*------------------ Alternatives for shadow placement -------------------*/
  101. #define BB_SUNAT_UL    0    /* Place the shadow at x+1, y+1   */
  102. #define BB_SUNAT_DL    16    /* Place the shadow at x+1, y-1   */
  103. #define BB_SUNAT_UR    32    /* Place the shadow at x-1, y+1   */
  104. #define BB_SUNAT_DR    48    /* Place the shadow at x-1, y-1   */
  105.  
  106. /*------------------------------------------------------------------------**
  107. **
  108. ** This is the structure that actually holds the definition of a single
  109. ** gadget.  It contains the new layout tags defined below, as well as the
  110. ** normal GadTools tags.  You setup all the gadgets in a window by
  111. ** making an array of this structure and passing it to GU_LayoutGadgetsA().
  112. **
  113. */
  114. struct LayoutGadget
  115. {
  116.     WORD    lg_GadgetID;
  117.     struct    TagItem *lg_LayoutTags;
  118.     struct    TagItem *lg_GadToolsTags;
  119.     struct    Gadget *lg_Gadget;
  120. };
  121.  
  122. /*------------------------------------------------------------------------**
  123. **
  124. ** Structure used to hold the built in strings of a localized program. These
  125. ** strings will be used if we couldn't get a string from the catalog.
  126. **
  127. */
  128. struct AppString
  129. {
  130.     LONG    as_ID;            /* String ID              */
  131.     LONG    as_Str;            /* String pointer          */
  132. };
  133.  
  134. /*------------------------------------------------------------------------**
  135. **
  136. ** GadUtil.library is basically an extension to Gadtools.library.  It adds
  137. ** to GadTools the ability to dynamically layout gadgets according to the
  138. ** positions of other gadgets, font size, locale, etc. The goal in designing
  139. ** this was to create a system so that programmers could easily create a GUI
  140. ** that automatically adjusted to a user's environment.
  141. **
  142. ** Every gadget is now defined as a TagList, there is no more need to make
  143. ** use of the NewGadget structure as this taglist allows you to access all
  144. ** fields used in that structure. An array of the TagLists for all your
  145. ** window's gadgets is then passed to GU_LayoutGadgetsA() and your gadget
  146. ** list is created.
  147. */
  148.  
  149. #define GU_TagBase    TAG_USER + 0x60000
  150.  
  151. /*********** Define which kind of gadget we are going to have. ************/
  152.  
  153. #define GU_GadgetKind    GU_TagBase+1    /* Which kind of gadget to make.  */
  154.  
  155.  
  156. /************************ Gadget width control. ***************************/
  157.  
  158. #define GU_Width    GU_TagBase+20    /* Absolute gadget width.      */
  159.  
  160. #define GU_DupeWidth    GU_TagBase+21    /* Duplicate the width of another
  161.                      * gadget.              */
  162.  
  163. #define GU_AutoWidth    GU_TagBase+22    /* Set width according to length
  164.                      * of text label + ti_Data.       */
  165.  
  166. #define GU_Columns    GU_TagBase+23    /* Set width so that approximately
  167.                      * ti_Data columns will fit.      */
  168.  
  169. #define GU_AddWidth    GU_TagBase+24    /* Add some value to the total
  170.                      * width calculation.          */
  171.  
  172. #define GU_MinWidth    GU_TagBase+25    /* Make sure width is at least this */
  173.  
  174. #define GU_MaxWidth    GU_TagBase+26    /* Make sure width is at most this */
  175.  
  176. #define GU_AddWidChar    GU_TagBase+27    /* Add the width of ti_Data chars
  177.                      *  to the gadget width          */
  178.  
  179. #define GU_FractWidth    GU_TagBase+28    /* Divide / multiply gadget width
  180.                      *  with ti_Data          */
  181.  
  182. /************************* Gadget height control. *************************/
  183.  
  184. #define GU_Height    GU_TagBase+40    /* Absolute gadget height.       */
  185.  
  186. #define GU_DupeHeight    GU_TagBase+41    /* Duplicate the height of another
  187.                      * gadget.              */
  188.  
  189. #define GU_AutoHeight    GU_TagBase+42    /* Set height according to height
  190.                      * of text font + ti_Data.      */
  191.  
  192. #define GU_HeightFactor    GU_TagBase+43    /* Make the gadget height a
  193.                      * multiple of the font height.      */
  194.  
  195. #define GU_AddHeight    GU_TagBase+44    /* Add some value to the total
  196.                      * height calculation.          */
  197.  
  198. #define GU_MinHeight    GU_TagBase+45    /* Make sure height is at least this */
  199.  
  200. #define GU_MaxHeight    GU_TagBase+46    /* Make sure height is at most this */
  201.  
  202. #define GU_AddHeiLines    GU_TagBase+47    /* Add the height of ti_Data lines
  203.                      *  to the gadget height      */
  204.  
  205. #define GU_FractHeight    GU_TagBase+48    /* Divide / multiply gadget height
  206.                      *  with ti_Data          */
  207.  
  208. /************************* Gadget top edge control. ***********************/
  209.  
  210. #define GU_Top        GU_TagBase+60    /* Absolute top edge.          */
  211.  
  212. #define GU_TopRel    GU_TagBase+61    /* Top edge relative to bottom
  213.                      * edge of another gadget.      */
  214.  
  215. #define GU_AddTop    GU_TagBase+62    /* Add some value to the final
  216.                      * top edge calculation.      */
  217.  
  218. #define GU_AlignTop    GU_TagBase+63    /* Align top edge of gadget with
  219.                      * top edge of another gadget.      */
  220.  
  221. #define GU_AdjustTop    GU_TagBase+64    /* Add the height of the text font
  222.                      * + ti_Data to the top edge.      */
  223.  
  224. #define GU_AddTopLines    GU_TagBase+65    /* Add the height of ti_Data lines
  225.                      * to the top edge.          */
  226.  
  227. /*********************** Gadget bottom edge control. **********************/
  228.  
  229. #define GU_Bottom    GU_TagBase+80    /* Absolute bottom edge.      */
  230.  
  231. #define GU_BottomRel    GU_TagBase+81    /* Bottom edge relative to top
  232.                      * edge of another gadget.      */
  233.  
  234. #define GU_AddBottom    GU_TagBase+82    /* Add some value to the final
  235.                      * bottom edge calculation.      */
  236.  
  237. #define GU_AlignBottom    GU_TagBase+83    /* Align bottom edge of gadget with
  238.                      * bottom edge of another gadget. */
  239.  
  240. #define GU_AdjustBottom    GU_TagBase+84    /* Subtract the height of the text
  241.                      * font + ti_Data from the top edge */
  242.  
  243. /********************** Gadget left edge control. *************************/
  244.  
  245. #define GU_Left        GU_TagBase+100    /* Absolute left edge.          */
  246.  
  247. #define GU_LeftRel    GU_TagBase+101    /* Left edge relative to right
  248.                      * edge of another gadget.      */
  249.  
  250. #define GU_AddLeft    GU_TagBase+102    /* Add some value to the final
  251.                      * left edge calculation.      */
  252.  
  253. #define GU_AlignLeft    GU_TagBase+103    /* Align left edge of gadget with
  254.                      * left edge of another gadget.      */
  255.  
  256. #define GU_AdjustLeft    GU_TagBase+104    /* Add the width of the text label
  257.                      * + ti_Data to the left edge.      */
  258.  
  259. #define GU_AddLeftChar    GU_TagBase+105    /* Add length of ti_Data characters
  260.                      * to the left edge.          */
  261.  
  262. /********************** Gadget right edge control. ************************/
  263.  
  264. #define GU_Right    GU_TagBase+120    /* Absolute right edge.          */
  265.  
  266. #define GU_RightRel    GU_TagBase+121    /* Right edge relative to left
  267.                      * edge of another gadget.      */
  268.  
  269. #define GU_AddRight    GU_TagBase+122    /* Add some value to the final
  270.                      * right edge calculation.      */
  271.  
  272. #define GU_AlignRight    GU_TagBase+123    /* Align right edge of gadget with
  273.                      * right edge of another gadget.  */
  274.  
  275. #define GU_AdjustRight    GU_TagBase+124    /* Subtract the width of the text
  276.                      * label + ti_Data from the left edge */
  277.  
  278. /******************************* Other tags *******************************/
  279.  
  280. #define GU_ToggleSelect    GU_TagBase+150    /* Create a toggle-select gadget -
  281.                      * only BUTTON_KIND & IMAGE_KIND  */
  282.  
  283. #define GU_Selected    GU_TagBase+151    /* Set default state of toggle-
  284.                      * select gadget          */
  285.  
  286. /********* Access to the other fields of the NewGadget structure **********/
  287.  
  288. #define GU_GadgetText    GU_TagBase+160    /* Gadget label.          */
  289.  
  290. #define GU_TextAttr    GU_TagBase+161    /* Desired font for gadget label. */
  291.  
  292. #define GU_Flags    GU_TagBase+162    /* Gadget flags.          */
  293.  
  294. #define GU_UserData    GU_TagBase+163    /* Gadget UserData.          */
  295.  
  296. #define GU_LocaleText    GU_TagBase+164    /* Gadget label taken from a locale. */
  297.  
  298. /*************** Tags for GadUtil's extended gadget kinds. *****************/
  299.  
  300. #define GUIM_Image    GU_TagBase+200    /* Image structure for an image
  301.                      * gadget.              */
  302.  
  303. #define GUIM_ReadOnly    GU_TagBase+201    /* TRUE if read-only.          */
  304.  
  305. #define GUIM_SelectImg    GU_TagBase+202    /* Selected image for IMAGE_KIND
  306.                      * gadgets              */
  307.  
  308. #define GUIM_BOOPSILook    GU_TagBase+203    /* Render selected image background
  309.                      * with the fillpen (default = TRUE) */
  310.                      
  311. #define GUBD_Border    GU_TagBase+200    /* Border structure for an border
  312.                      * gadget.              */
  313.  
  314. #define GUBD_ReadOnly    GU_TagBase+201    /* TRUE if read-only.          */
  315.  
  316. #define GUBB_Recessed    GU_TagBase+220    /* TRUE for a recessed bevel box  */
  317.  
  318. #define GUBB_FrameType    GU_TagBase+221    /* Frame type for bevel box      */
  319.  
  320. #define GUBB_TextColor    GU_TagBase+222    /* Color of the title text      */
  321.  
  322. #define GUBB_TextPen    GU_TagBase+223    /* Pen to print title text with -
  323.                      *  overrides GUBB_TextColor      */
  324.  
  325. #define GUBB_Flags    GU_TagBase+224    /* Text placement flags          */
  326.  
  327. #define GUBB_3DText    GU_TagBase+225    /* Tag to enable 3D text (shadow)
  328.                      *  Not needed if GU_ShadowColor or
  329.                      *  GU_ShadowPen is used      */
  330.  
  331. #define GUBB_ShadowColor GU_TagBase+226 /* Color of the title text's shadow */
  332.  
  333. #define GUBB_ShadowPen    GU_TagBase+227    /* Pen to print the text's shadow
  334.                      *  with - overrides GUBB_ShadowColor */
  335.  
  336. #define GUPR_FillColor    GU_TagBase+240    /* Color of filled part of indicator */
  337.  
  338. #define GUPR_FillPen    GU_TagBase+241    /* Pen to fill the indicator with
  339.                      *  - overrides GUPR_FillColor      */
  340.  
  341. #define GUPR_BackColor    GU_TagBase+242    /* Color of the background of the
  342.                      *  indicator              */
  343.  
  344. #define GUPR_BackPen    GU_TagBase+243    /* Pen to use for the indocator's
  345.                      *  background - overrides
  346.                      *  GUPR_BackColor          */
  347.  
  348. #define GUPR_Current    GU_TagBase+244    /* Current value of the indicator */
  349.  
  350. #define GUPR_Total    GU_TagBase+245    /* Total value for the indicator  */
  351.  
  352. /************** Tags passed directly to GU_LayoutGadgetsA(). **************/
  353.  
  354. #define GU_RightExtreme    GU_TagBase+500    /* ti_Data is a pointer to a LONG
  355.                      * that is used to store the right-
  356.                      * most point that a gadget
  357.                      * will exist in.          */
  358.  
  359. #define GU_LowerExtreme    GU_TagBase+501    /* ti_Data is a pointer to a LONG
  360.                      * that is used to store the lower-
  361.                      * most point that a gadget will
  362.                      * exist in.              */
  363.  
  364. #define GU_Catalog    GU_TagBase+502    /* Indicates locale for the gadgets. */
  365.  
  366.  
  367. #define GU_DefTextAttr    GU_TagBase+503    /* Specifies a default font for use
  368.                      * with all gadgets, can still be
  369.                      * over-ridden with GU_TextAttr.  */
  370.  
  371. #define GU_AppStrings    GU_TagBase+504    /* Application string table w/IDs. */
  372.  
  373. #define GU_BorderLeft    GU_TagBase+505    /* Size of window left border.      */
  374.  
  375. #define GU_BorderTop    GU_TagBase+506    /* Size of window top border.      */
  376.  
  377. #define GU_NoCreate     GU_TagBase+507    /* Don't actually create the gadgets. */
  378.  
  379. #define GU_MinimumIDCMP GU_TagBase+508    /* Minimum required IDCMP, so that
  380.                      *  all gadgets will work      */
  381.  
  382. /***************************** Hotkey tags ********************************/
  383.  
  384. #define GU_Hotkey    GU_TagBase+300    /* Hotkey for gadget (VANILLAKEY) */
  385.  
  386. /********************* Boolean flags for hotkey code **********************/
  387.  
  388. #define GU_HotkeyCase    GU_TagBase+301    /* TRUE for a case-sensitive hotkey */
  389. #define GU_LabelHotkey    GU_TagBase+302    /* TRUE = get hotkey code from label */
  390. #define GU_RawKet    GU_TagBase+303    /* TRUE if hotkey is a RAWKEY code */
  391.  
  392. /*********************** Constants for hotkey support *********************/
  393.  
  394. #define GADUSERMAGIC    0x1122        /* Identification for structure that
  395.                      * the gadgets UserData points to */
  396.  
  397. /******************* Public bit numbers for gu_Flags **********************/
  398.  
  399. #define GU_HOTKEYCASE    0        /* Hoykey is case-sensitive      */
  400. #define GU_RAWKEY    2        /* gu_Code is a RAWKEY code      */
  401.  
  402. #define GU_HOTKEYCASEMASK 1<<GU_HOTKEYCASE /* Mask for GU_HOTKEYCASE bit  */
  403. #define GU_RAWKEYMASK      1<<GU_RAWKEY       /* Mask for GU_RAWKEY bit      */
  404.  
  405. /************** Structure the gadget's UserData points to ******************
  406. *
  407. * This structure is the public part of the allocated data structure for
  408. * hotkeys and IMAGE_KIND gadgets (including FILE_KIND and DRAWER_KIND).
  409. *
  410. * This structure should be considered READ ONLY. The only fields you may
  411. * change is the gu_Code and gu_Flags fields.
  412. *
  413. * DO NOT WRITE ANYTHING BEYOND THIS STRUCTURE WITHOUT ALLOCATING MEMORY FIRST
  414. *
  415. */
  416.  
  417. struct GU_Public
  418. {
  419.     UWORD    gu_Magic;    /* Identification word for structure      */
  420.     ULONG    gu_GadFlags;    /* Flags for GENERIC kind GadUtil gadgets */
  421.     UBYTE    gu_Flags;    /* Flags for the hotkey type          */
  422.     UBYTE    gu_Code;    /* VANILLA or RAWKEY code to react on      */
  423.     WORD    gu_Active;    /* Active entry for some gadget kinds      */
  424.     WORD    gu_MaxVal;    /* Maximum value for some gadgets      */
  425.     WORD    gu_MinVal;    /* Minimum value for some gadgets      */
  426.     ULONG    gu_GadgetType;    /* Gadget type that was created          */
  427. };
  428.  
  429. /*------------------------------------------------------------------------**
  430. **                  Library base                  **
  431. **------------------------------------------------------------------------*/
  432.  
  433. struct GadUtilBase
  434. {
  435.         struct    Library LibNode;
  436.         UBYTE   gub_Flags;        /* Private!              */
  437.     UBYTE    gub_Pad;        /* Private!              */
  438.  
  439.     struct    Library *GadToolsBase;    /* The following library bases      */
  440.     struct    GfxBase    *GfxBase;    /* may be read and used by your      */
  441.     struct    IntuitionBase *IntuitionBase;    /* program          */
  442.     struct    Library *LocaleBase;    /* LocaleBase may be NULL!      */
  443.     struct    Library *UtilityBase;
  444.     struct    Library *DiskFontBase;    /* DiskFontBase may be NULL!      */
  445.     LONG    gub_SegList;        /* Private!              */
  446. };
  447.  
  448. #define GADUTILNAME     "gadutil.library"
  449.  
  450. /*------------------------------------------------------------------------**
  451. **                  BevelBox structure              **
  452. **------------------------------------------------------------------------*/
  453. struct BBoxData
  454. {
  455.     UWORD    bbd_XPos;         /* X position of box          */
  456.     UWORD    bbd_YPos;         /* Y position of box          */
  457.     UWORD    bbd_Width;        /* Width of box              */
  458.     UWORD    bbd_Height;        /* Height of box          */
  459.  
  460.     UWORD    bbd_LeftEdge;        /* Left edge of text          */
  461.     UWORD    bbd_TopEdge;        /* Top edge of text          */
  462.     UWORD    bbd_TextWidth;        /* Pixel width of text          */
  463.  
  464.     struct    TextAttr *bbd_TextFont; /* Font to print text with      */
  465.     STRPTR    bbd_Text;        /* Text to display          */
  466.         
  467.     UBYTE    bbd_FrontPen;        /* Text color              */
  468.     UBYTE    bbd_Flags;        /* Text placement flags          */
  469.     UBYTE    bbd_Recessed;        /* Recessed frame          */
  470.     UBYTE    bbd_FrameType;        /* Type of box frame          */
  471.     UBYTE    bbd_ShadowPen;             /* Shadow color              */
  472.     UBYTE    bbd_Reserved1;        /* No use in v36.53 - reserved!      */
  473. };
  474.  
  475. /*------------------------------------------------------------------------**
  476. **              ProgressIndicator structure              **
  477. **------------------------------------------------------------------------*/
  478.  
  479. struct ProgressGad
  480. {
  481.     UWORD    pg_XPos;        /* X pos of box around gadget      */
  482.     UWORD    pg_YPos;        /* Y pos of box around gadget      */
  483.     UWORD    pg_Width;        /* Width of box around gadget      */
  484.     UWORD    pg_Height;        /* Height of box around gadget      */
  485.     ULONG    pg_Current;        /* Current value of indicator      */
  486.     ULONG    pg_Total;        /* Total value of indicator      */
  487.     UBYTE    pg_FillColor;        /* Color of upto current value      */
  488.     UBYTE    pg_BackColor;        /* Color from current to end      */
  489.     UBYTE    pg_Flags;        /* Flags              */
  490.     UBYTE    pg_reserved1;
  491.     UWORD    pg_XFilledTo;        /* Initialized to pg_XPos + 4      */
  492. };
  493.  
  494. #endif /* LIBRARIES_GADUTIL_H */
  495.